﻿<UserControl x:Class="uTorrentNetClient.ModelDesign.EditSettings.View.EditSettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sCon="clr-namespace:uTorrentNetClient.ModelDesign.Converter.Settings"
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             mc:Ignorable="d"
             Height="500" Width="600">
    <UserControl.Resources>
        <CollectionViewSource Source="{Binding Path=GroupMappingCollection}" x:Key="Mapping">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="Key" Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource Source="{Binding Path=ConverterTypes}" x:Key="ConverterTypes">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource Source="{Binding Path=ValueTypes}" x:Key="ValueTypes">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>

        <CollectionViewSource Source="{Binding Path=MappingGroups}" x:Key="MappingGroups">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="Position" Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250"/>
            <ColumnDefinition Width="350"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="20"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>

        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Grid.ColumnSpan="2">
            <Button Margin="1" Content="x" HorizontalAlignment="Right" Command="{Binding Path=CancelCommand}"/>
        </Border>

        <ListView Background="Transparent" ItemsSource="{Binding Source={StaticResource MappingGroups}}" Margin="0" Grid.Column="0" Grid.Row="1" SelectedItem="{Binding Path=SelectedMainMappingGroup}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=Position}" Width="40"/>
                        <TextBlock Text="{Binding Path=GroupName}" />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <ListBox Background="Transparent" ItemsSource="{Binding Source={StaticResource Mapping}}" Grid.Column="0" Grid.Row="2" SelectedItem="{Binding Path=SelectedMapping}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Label Content="{Binding Path=Key}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Grid Grid.Column="1" Grid.Row="1" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="240"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="70"/>
                <RowDefinition Height="70"/>
                <RowDefinition Height="3"/>
                <RowDefinition Height="70"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
                <RowDefinition Height="25"/>
            </Grid.RowDefinitions>

            <TextBlock Text="Key" FontWeight="Bold" Grid.Column="0" Grid.Row="0" Margin="3,0,0,0"/>
            <TextBlock Text="{Binding Path=SelectedMapping.Key}" Grid.Column="1" Grid.Row="0"/>

            <TextBlock Text="Name" FontWeight="Bold" Grid.Column="0" Grid.Row="1" Margin="3,0,0,0"/>
            <TextBox Text="{Binding Path=SelectedMapping.Name}" Grid.Column="1" Grid.Row="1"/>

            <TextBlock Text="Position" FontWeight="Bold" Grid.Column="0" Grid.Row="2" Margin="3,0,0,0"/>
            <TextBox Text="{Binding Path=SelectedMapping.Position}" Grid.Column="1" Grid.Row="2"/>

            <TextBlock Text="Verbergen" FontWeight="Bold" Grid.Column="0" Grid.Row="3" Margin="3,0,0,0"/>
            <CheckBox IsChecked="{Binding Path=SelectedMapping.Hide}" Grid.Column="1" Grid.Row="3"/>

            <TextBlock Text="Konverter" FontWeight="Bold" Grid.Column="0" Grid.Row="4" Margin="3,0,0,0"/>
            <ListView ItemsSource="{Binding Source={StaticResource ConverterTypes}}" Margin="0" Grid.Column="1" Grid.Row="4" SelectedItem="{Binding Path=SelectedMapping.Converter}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <TextBlock Text="Typ" FontWeight="Bold" Grid.Column="0" Grid.Row="5" Margin="3,0,0,0"/>
            <ListView ItemsSource="{Binding Source={StaticResource ValueTypes}}" Margin="0" Grid.Column="1" Grid.Row="5" SelectedItem="{Binding Path=SelectedMapping.ValueType}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <Line Fill="Black" Grid.ColumnSpan="2" Grid.Row="6"/>

            <TextBlock Text="Gruppe" FontWeight="Bold" Grid.Column="0" Grid.Row="7" Margin="3,0,0,0"/>
            <ListView ItemsSource="{Binding Source={StaticResource MappingGroups}}" Margin="0" Grid.Column="1" Grid.Row="7" SelectedItem="{Binding Path=SelectedMappingGroup}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Position}" Width="40"/>
                            <TextBlock Text="{Binding Path=GroupName}" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>



            <TextBlock Text="Neue Gruppe" FontWeight="Bold" Grid.ColumnSpan="2" Grid.Row="8" Margin="3,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>

            <TextBlock Text="Name" FontWeight="Bold" Grid.Column="0" Grid.Row="9" Margin="3,0,0,0"/>
            <TextBox Text="{Binding Path=SelectedGroupText}" Grid.Column="1" Grid.Row="9"/>


            <TextBlock Text="Position" FontWeight="Bold" Grid.Column="0" Grid.Row="10" Margin="3,0,0,0"/>
            <TextBox Text="{Binding Path=SelectedGroupPosition}" Grid.Column="1" Grid.Row="10"/>

            <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="11">
                <Button Content="Hinzufügen" HorizontalAlignment="Right" Command="{Binding Path=AddGroupCommand}" Margin="3"/>
                <Button Content="Löschen" HorizontalAlignment="Right" Command="{Binding Path=DelGroupCommand}" Margin="3"/>
                <Button Content="Neu" HorizontalAlignment="Right" Command="{Binding Path=ClearGroupCommand}" Margin="3"/>
            </StackPanel>

        </Grid>

        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="3" Grid.ColumnSpan="2">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Margin="2" Content="OK" Command="{Binding Path=OkCommand}"/>
                <Button Margin="2" Content="Abbrechen" Command="{Binding Path=CancelCommand}"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
